<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="crm.util.ParamUtil"%>
<%@page import="java.util.*"%>
<%@page import="crm.util.GetBaseParam"%>
<%@page import="crm.control.SaleareaControl"%>
<%@page import="crm.control.EmployeesControl"%>
<%@page import="crm.model.Employees"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>天成科技CRM管理系统</title>
<!--                       CSS                       -->
<!-- Reset Stylesheet -->
<link rel="stylesheet" href="../../../resources/css/reset.css" type="text/css" media="screen" />
<!-- Main Stylesheet -->
<link rel="stylesheet" href="../../../resources/css/style.css" type="text/css" media="screen" />
<!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
<link rel="stylesheet" href="../../../resources/css/invalid.css" type="text/css" media="screen" />
<!--                       Javascripts                       -->
<!-- jQuery -->
<script type="text/javascript" src="../../../resources/scripts/jquery-1.3.2.min.js"></script>
<!-- jQuery Configuration -->
<script type="text/javascript" src="../../../resources/scripts/simpla.jquery.configuration.js"></script>
 <script type="text/javascript" src="../../../resources/js/WebCalendar.js"></script>
<!-- Facebox jQuery Plugin -->
<script type="text/javascript" src="../../../resources/scripts/facebox.js"></script>
<!-- jQuery WYSIWYG Plugin -->
<script type="text/javascript" src="../../../resources/scripts/jquery.wysiwyg.js"></script>
<!-- jQuery Datepicker Plugin -->
<script type="text/javascript" src="../../../resources/scripts/jquery.datePicker.js"></script>
<script type="text/javascript" src="../../../resources/scripts/jquery.date.js"></script>
<script type="text/javascript" src="../../../resources/js/reinitIframe.js"></script>
<script type='text/javascript'>
window.onload=function(){
	var num=document.getElementById('num').value;
	setInterval(function(){
		new ReinitIframe('iadd');
		new ReinitIframe('iinformation');
		for(var i=1;i<=num;i++){
			var check = 'icheck' + i;
			var update = 'iupdate' + i;
			new ReinitIframe(check);
			new ReinitIframe(update);
		}
	},200);
}


</script>
<style type="text/css">
.hide{
    position: absolute;
    zoom: 0.001;
    -moz-transform: scale(0);
    -webkit-transform: scale(0);
    -o-transform: scale(0);
    transform: scale(0);
}
</style>
</head>
	<body>
		<%
			Employees cu = (Employees)session.getAttribute("user");
			request.setCharacterEncoding("UTF-8");
			String idcard = "";
			String username = "";
			String gender = "";
			String nation = "";
			String polity = "";
			String is_married = "";
			String home_type = "";
			String position = "";
			String edu_level = "";
			String area_id = "";

			int type = ParamUtil.getInt(request, "type", 1);
			if (type == 1) {
				idcard = ParamUtil.getString(request, "idcard", null);
				username = ParamUtil.getString(request, "username", null);
				gender = ParamUtil.getString(request, "gender", null);
				nation = ParamUtil.getString(request, "nation", null);
				polity = ParamUtil.getString(request, "polity", null);
				is_married = ParamUtil.getString(request, "is_married", null);
				home_type = ParamUtil.getString(request, "home_type", null);
				position = ParamUtil.getString(request, "position", null);
				edu_level = ParamUtil.getString(request, "edu_level", null);
				area_id = ParamUtil.getString(request, "area_id", null);

				session.setAttribute("idcard", idcard);
				session.setAttribute("username", username);
				session.setAttribute("gender", gender);
				session.setAttribute("nation", nation);
				session.setAttribute("polity", polity);
				session.setAttribute("is_married", is_married);
				session.setAttribute("home_type", home_type);
				session.setAttribute("position", position);
				session.setAttribute("edu_level", edu_level);
				session.setAttribute("area_id", area_id);
			} else {
				idcard = (String) session.getAttribute("idcard");
				username = (String) session.getAttribute("username");
				gender = (String) session.getAttribute("gender");
				nation = (String) session.getAttribute("nation");
				polity = (String) session.getAttribute("polity");
				is_married = (String) session.getAttribute("is_married");
				home_type = (String) session.getAttribute("home_type");
				position = (String) session.getAttribute("position");
				edu_level = (String) session.getAttribute("edu_level");
				area_id = (String) session.getAttribute("area_id");
			}
		%>
<div id="body-wrapper">
  <!-- Wrapper for the radial gradient background -->
  <div id="sidebar">
    <div id="sidebar-wrapper">
      <!-- Sidebar with logo and menu -->
      <h1 id="sidebar-title"><a href="#">Simpla Admin</a></h1>
      <!-- Logo (221px wide) -->
      <a href="#"><img id="logo" src="../../../resources/css/slice/notice.png" alt="Simpla Admin logo" /></a>
      <!-- Sidebar Profile links -->
      <div id="profile-links"> <a href="#"><%=EmployeesControl.getEmployeesName(cu.getId())%>,您好！</a> <br />
        <br />
        <a href="#information" rel='modal' >修改个人信息</a> | <a href="../../login/logout.jsp" title="Sign Out">注销</a> </div>
      <ul id="main-nav">
        <!-- Accordion Menu -->
       <li> <a href="#" class="nav-top-item">公司页面 </a>
          <ul>
	          <li><a href='../company/material/material_download.jsp'>资料 </a></li>
	          <li><a href='../company/notice/notice.jsp'>公告</a></li>
	          <li><a href='../company/salearea/salearea.jsp'>销售区域</a></li>
	          <li><a href='../company/saletarget/saletarget.jsp'>销售目标</a></li>
	          <li><a href='../company/show_all_custom_require.jsp'>客户需求登记表</a></li>
          </ul>
         </li>
        <li> <a href="../recepit/show_all_recepits.jsp" class="nav-top-item no-submenu">
          <!-- Add the class "current" to menu item -->
           我的跟单</a>

        </li>
        <li> <a href="../offer/show_all_offers.jsp" class="nav-top-item no-submenu">报<span class='letter'>价</span></a>      
        </li>
        <li> <a href="../bargain/show_all_bargains.jsp" class="nav-top-item no-submenu">合<span class='letter'>同</span></a>
        </li>
        <li> <a href="../schedule/schedule.jsp" class="nav-top-item no-submenu">日<span class='letter'>程</span></a></li>
        <li> <a href="../customer/customer.jsp" class="nav-top-item no-submenu">我的客户</a>
        <%
            if(cu.getPosition()!=1){
            	%>
            	<li> <a href="#" class="nav-top-item">统<span class='letter'>计</span></a>
		          <ul>
		            <li><a href="../../control/statistics/company_statistics.jsp">公司统计</a></li>
		            <li><a href="../../control/statistics/employees_statistics.jsp">员工统计</a></li>
		          </ul>
		        </li>
		        <li><a href="../employees/employees.jsp" class="nav-top-item current no-submenu">员工管理</a></li>
            	<%
            }
        %>
        </li>
      </ul>
    </div>
  </div>
  <div id="main-content">
  <img src='../../../resources/css/slice/t.png'/>
  <form action="employees.jsp" method="post">
	 <div class="content-box-header">
	 <h3 style="cursor: s-resize;">搜索条件</h3>
	 </div>
	 <table border='1'>
					<tr>
						<td>
							身份证号
						</td>
						<td>
							<input type="text" name="idcard" value="<%if(idcard!=null&&!idcard.equals(""))out.print(idcard);%>"/>
						</td>

						<td>
							民族
						</td>
						<td>
							<select name="nation" style='width:100px;'>
								<option value="">
									请选择
								</option>
								<%
									HashMap nations = GetBaseParam.getAllNations();
									Iterator it1 = nations.entrySet().iterator();
									while (it1.hasNext()) {
										Map.Entry entry = (Map.Entry) it1.next();
								%>
								<option value="<%=entry.getKey()%>"
									<%if (nation != null && nation.equals("" + entry.getKey()))
					out.print("selected");%>><%=entry.getValue()%></option>
								<%
									}
								%>
							</select>
						</td>
						<td>
							性别
						</td>
						<td>
							<input type="radio" name="gender" value="1" <%if(gender!=null&&gender.equals("1"))out.print("checked");%>/>
							男
							<input type="radio" name="gender" value="0" <%if(gender!=null&&gender.equals("0"))out.print("checked");%>/>
							女
							<input type="radio" name="gender" value="" <%if(gender==null||gender.equals(""))out.print("checked");%>/>
							全部
						</td>
						<td>
							姓名
						</td>
						<td>
							<input type="text" name="username" value="<%if(username!=null&&!username.equals(""))out.print(username);%>"/>
						</td>
						<td>
							政治面貌
						</td>
						<td>
							<select name="polity" style='width:100px;'>
								<option value="">
									请选择
								</option>
								<%
									HashMap politys = GetBaseParam.getAllPolities();
									Iterator it2 = politys.entrySet().iterator();
									while (it2.hasNext()) {
										Map.Entry entry = (Map.Entry) it2.next();
								%>
								<option value="<%=entry.getKey()%>"
									<%if (polity != null && polity.equals("" + entry.getKey()))
					out.print("selected");%>><%=entry.getValue()%></option>
								<%
									}
								%>
							</select>
						</td>
						<td rowspan='2' style='text-align: center; vertical-align:middle;'><input class='button' style="height:40px; width:40px;" type="submit" value="查询"/></td>
							</tr>
						
						<tr class="alt-row">
						<td>
							婚否
						</td>
						<td>
							<input type="radio" name="is_married" value="1" <%if(is_married!=null&&is_married.equals("1"))out.print("checked");%>/>
							已婚
							<input type="radio" name="is_married" value="0" <%if(is_married!=null&&is_married.equals("0"))out.print("checked");%>/>
							未婚
							<input type="radio" name="is_married" value="" <%if(is_married==null||is_married.equals(""))out.print("checked");%>/>
							全部
						</td>
						<td>
							职务
						</td>
						<td>
							<select name="position" style='width:100px;'>
								<option value="">
									请选择
								</option>
								<%
									HashMap positions = GetBaseParam.getAllPostions();
									Iterator it3 = positions.entrySet().iterator();
									while (it3.hasNext()) {
										Map.Entry entry = (Map.Entry) it3.next();
								%>
								<option value="<%=entry.getKey()%>"
									<%if (position != null && position.equals("" + entry.getKey()))
					out.print("selected");%>><%=entry.getValue()%></option>
								<%
									}
								%>
							</select>
						</td>
						<td>
							学历
						</td>
						<td>
							<select name="edu_level" style='width:120px;'>
								<option value="" <%if(edu_level==null||edu_level.equals(""))out.print("selected='selected'");%>>
									请选择
								</option>
								<option value="小学" <%if(edu_level!=null&&edu_level.equals("小学"))out.print("selected='selected'");%>>
									小学
								</option>
								<option value="初中" <%if(edu_level!=null&&edu_level.equals("初中"))out.print("selected='selected'");%>>
									初中
								</option>
								<option value="高中" <%if(edu_level!=null&&edu_level.equals("高中"))out.print("selected='selected'");%>>
									高中
								</option>
								<option value="专科" <%if(edu_level!=null&&edu_level.equals("专科"))out.print("selected='selected'");%>>
									专科
								</option>
								<option value="本科" <%if(edu_level!=null&&edu_level.equals("本科"))out.print("selected='selected'");%>>
									本科
								</option>
								<option value="研究生" <%if(edu_level!=null&&edu_level.equals("研究生"))out.print("selected='selected'");%>>
									研究生
								</option>
								<option value="硕士" <%if(edu_level!=null&&edu_level.equals("硕士"))out.print("selected='selected'");%>>
									硕士
								</option>
								<option value="博士" <%if(edu_level!=null&&edu_level.equals("博士"))out.print("selected='selected'");%>>
									博士
								</option>
								<option value="博士后" <%if(edu_level!=null&&edu_level.equals("博士后"))out.print("selected='selected'");%>>
									博士后
								</option>
							</select>
						</td>
						<td>
							生源类别
						</td>
						<td>
							<input type="radio" name="home_type" value="1" <%if(home_type!=null&&home_type.equals("1"))out.print("checked");%>/>
							城市
							<input type="radio" name="home_type" value="0" <%if(home_type!=null&&home_type.equals("0"))out.print("checked");%>/>
							农村
							<input type="radio" name="home_type" value="" <%if(home_type==null||home_type.equals(""))out.print("checked");%>/>
							全部
						</td>
						<td>
							所属区域
						</td>
						<td>
							<select name="area_id" style='width:100px;'>
								<option value="">
									请选择
								</option>
								<%
									HashMap areas = SaleareaControl.getAllSaleArea();
									Iterator it4 = areas.entrySet().iterator();
									while (it4.hasNext()) {
										Map.Entry entry = (Map.Entry) it4.next();
								%>
								<option value="<%=entry.getKey()%>"
									<%if (area_id != null && area_id.equals("" + entry.getKey()))
					out.print("selected");%>><%=entry.getValue()%></option>
								<%
									}
								%>
							</select>
						</td>
					</tr>
				</table>
		</form>

		<form>
 <div class="content-box-header">
<h3 style="cursor: s-resize;">搜索结果</h3>
</div>
				<table>
					<thead>
						<tr>
							<th>
								姓名
							</th>
							<th>
								性别
							</th>
							<th>
								婚否
							</th>
							<th>
								民族
							</th>
							<th>
								用户名
							</th>
							<th>
								职务
							</th>
							<th>
								操作
							</th>
						</tr>
					</thead>
					<tbody>
						<%
							request.setCharacterEncoding("UTF-8");
							int pages = ParamUtil.getInt(request, "pages", 0);
							int i = 0;
							int rowsPerPage = ParamUtil.getInt(request, "rowsPerPage", 10);
							Collection employees = EmployeesControl.searchEmployees(idcard,
									username, gender, nation, polity, is_married, home_type,
									position, edu_level, area_id, rowsPerPage, pages);
							Iterator iterator = employees.iterator();
							while (iterator.hasNext()) {
								Employees employees2 = (Employees) iterator.next();
								i++;
						%>
						<tr>
							<td><%=employees2.getName()%></td>
							<td><%if(employees2.getGender().equals("1"))out.print("男");else out.print("女");%></td>
							<td><%if(employees2.getIs_married().equals("1"))out.print("已婚");else out.print("未婚");%></td>
							<td><%=GetBaseParam.getNationById(employees2.getNation())%></td>
							<td><%=employees2.getUsername()%></td>
							<td><%=GetBaseParam.getPositionById(employees2.getPosition())%></td>
							<td align="center">
							    <a href="#message<%=i %>" rel='modal'>查看</a>
							    <a>|</a>
								<a href="#messages<%=i %>" rel='modal'>修改</a>
								<a>|</a>
								<a href="employees_delete.jsp?id=<%=employees2.getId()%>"
									onclick='return confirm("确定要删除吗?")'>删除</a>
							</td>
						</tr>
						<div  class='hide'>
				        <div id='message<%=i %>'>
						<iframe id='icheck<%=i %>'style='width:368px; overflow:hidden;' scrolling='no' frameborder='0'  src='readme.jsp?id=<%=employees2.getId()%>'></iframe>
						</div>
						</div>
						<div  class='hide'>
						<div id='messages<%=i %>'>
						<iframe id='iupdate<%=i %>' style='width:368px; overflow:hidden;' scrolling='no' frameborder='0' src='employees_update.jsp?id=<%=employees2.getId()%>'></iframe>
						</div>
						</div>
						<%
							}
						%>
						<input type='hidden' value='<%=i %>' id='num'/>
					</tbody>
				</table>
				<%
					out.println(EmployeesControl.pageInstance.getToolsMenu(pages));
				%>
				<br/>
				<a class='button' href="#add" rel='modal' />添加员工信息</a>
		</form>
		<div class='hide'>
		<div id='add'>
		<iframe id='iadd' style='width:368px; overflow:hidden;' scrolling='no' frameborder='0' src='employees_add.jsp'></iframe>
		</div>
		</div>
		<div class='hide' >
			<div id='information'>
				<iframe id='iinformation' style='width:368px; overflow:hidden;' scrolling='no' frameborder='0' src='../employees/employees_update.jsp'></iframe>
			</div>
		</div>
		</div>
		</div>
	</body>
</html>